package com.ruoyi.web.controller.project;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.project.domain.OrderReport;
import com.ruoyi.project.service.IOrderReportService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 订单维护状态报告Controller
 * 
 * @author phil
 * @date 2020-07-17
 */
@Controller
@RequestMapping("/project/report")
public class OrderReportController extends BaseController{
	private String prefix = "project/report";

	@Autowired
	private IOrderReportService orderReportService;

	@RequiresPermissions("project:report:view")
	@GetMapping()
	public String report(){
		return prefix + "/report";
	}

	/**
	 * 查询订单维护状态报告列表
	 */
	@RequiresPermissions("project:report:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(OrderReport orderReport){
		startPage();
		List<OrderReport> list = orderReportService.selectOrderReportList(orderReport);
		return getDataTable(list);
	}

	/**
	 * 导出订单维护状态报告列表
	 */
	@RequiresPermissions("project:report:export")
	@Log(title = "订单维护状态报告", businessType = BusinessType.EXPORT)
	@PostMapping("/export")
	@ResponseBody
	public AjaxResult export(OrderReport orderReport){
		List<OrderReport> list = orderReportService.selectOrderReportList(orderReport);
		ExcelUtil<OrderReport> util = new ExcelUtil<OrderReport>(OrderReport.class);
		return util.exportExcel(list, "report");
	}

	/**
	 * 新增订单维护状态报告
	 */
	@GetMapping("/add")
	public String add(){
		return prefix + "/add";
	}

	/**
	 * 新增保存订单维护状态报告
	 */
	@RequiresPermissions("project:report:add")
	@Log(title = "订单维护状态报告", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(OrderReport orderReport){
		return toAjax(orderReportService.insertOrderReport(orderReport));
	}

	/**
	 * 修改订单维护状态报告
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Long id, ModelMap mmap){
		OrderReport orderReport = orderReportService.selectOrderReportById(id);
		mmap.put("orderReport", orderReport);
		return prefix + "/edit";
	}

	/**
	 * 修改保存订单维护状态报告
	 */
	@RequiresPermissions("project:report:edit")
	@Log(title = "订单维护状态报告", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(OrderReport orderReport){
		return toAjax(orderReportService.updateOrderReport(orderReport));
	}

	/**
	 * 删除订单维护状态报告
	 */
	@RequiresPermissions("project:report:remove")
	@Log(title = "订单维护状态报告", businessType = BusinessType.DELETE)
	@PostMapping("/remove")
	@ResponseBody
	public AjaxResult remove(String ids){
		return toAjax(orderReportService.deleteOrderReportByIds(ids));
	}
}
